import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'modes/updateItem.dart';

class UpdateItem extends StatelessWidget {

  final UpdateItemModel model;
  final VoidCallback onPressed;

  UpdateItem({Key key, this.model, this.onPressed}) : super(key:key);

  @override
  Widget build(BuildContext context) {
    
    return Column(children: [
      buildTopRow(context),
      buildBottomRow(context)
    ],);
  }

  Widget buildTopRow(BuildContext context){
    return Row(
      children: [
        Padding(padding: EdgeInsets.all(10),
          child: ClipRRect(
            borderRadius: BorderRadius.circular(8.0),
            child: Image.asset(model.appIcon,width: 80,height: 80,),
          )
        ),
        Expanded(child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(model.appName, maxLines: 1,),
            Text(model.appDate,maxLines: 1,)
          ],
        )),
        Padding(padding: EdgeInsets.all(10),
            child: TextButton(onPressed: null, child: Text("Open"))
        )
      ],
    );
  }

  Widget buildBottomRow(BuildContext context) {
    return Padding(padding: EdgeInsets.all(10),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(model.appDescription),
            Padding(padding: EdgeInsets.fromLTRB(0, 10, 0, 0),
              child: Text("${model.appVersion} * ${model.appSize} MB") ,)
          ],
         )
    );
  }
}